package com.lingnan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lingnan.entity.po.Interview;
import lombok.Data;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
* @author abc20
* @description 针对表【interview(面试安排记录表)】的数据库操作Mapper
* @createDate 2025-07-16 10:16:50
* @Entity com.lingnan.domain.Interview
*/
public interface InterviewMapper extends BaseMapper<Interview> {

    /**
     * 查询需要提醒的面试记录（面试前30分钟和1小时）
     */
    @Select("SELECT i.*, ja.seeker_id, hr.user_account_id as hr_user_id " +
            "FROM interview i " +
            "LEFT JOIN job_application ja ON i.application_id = ja.id " +
            "LEFT JOIN company_hr hr ON i.hr_id = hr.id " +
            "WHERE i.status = 0 " +
            "AND i.interview_time BETWEEN #{startTime} AND #{endTime}")
    List<InterviewWithUserInfo> getInterviewsForReminder(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    /**
     * 内部类，用于返回包含用户信息的面试记录
     */
    @Data
    class InterviewWithUserInfo extends Interview {
        private Long seekerId;
        private Long hrUserId;
    }

}




